import 'package:cat_eye/config/string_config.dart';
import 'package:cat_eye/config/url_config.dart';
import 'package:cat_eye/http/http_manager.dart';
import 'package:cat_eye/provider/provider_widget.dart';
import 'package:cat_eye/root_page/home_page/home_banner_page_widget.dart';
import 'package:cat_eye/util/loading_state_widget_util.dart';
import 'package:cat_eye/util/util.dart';
import 'package:cat_eye/view_model/home_view_model/home_body_view_model.dart';
import 'package:flutter/material.dart';

/*
* @Package: root_page.home_page
* @ClassName: home_body_page
* @Author: szj
* @CreateDate: 7/28/21 3:46 PM
*/
class HomeBodyPageWidget extends StatefulWidget {
  const HomeBodyPageWidget({Key key}) : super(key: key);

  @override
  _HomeBodyPageWidgetState createState() => _HomeBodyPageWidgetState();
}

class _HomeBodyPageWidgetState extends State<HomeBodyPageWidget> {
  @override
  Widget build(BuildContext context) {
    return ProviderWidget<HomeBodyViewModel>(
      model: HomeBodyViewModel(),
      onModelInit: (model) => model.requestHttpData(),
      builder: (context, model, child) {
        return LoadingWidget(
          child: Column(
            children: [
              HomeBannerPageWidget(
                bannerList: model.bannerList,
              )

            ],
          ),
          type: model.type,
          //重新加载
          reload: () {
            model.requestHttpData();
            snackBar(context, StringConfig.RELOADING);
          },
        );
      },
    );
  }
}
